package de.gwtprime.client.widgets.trading;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

import de.gwtprime.client.ClientFactory;
import de.gwtprime.client.util.GWTUtils;
import de.gwtprime.shared.requestFactory.OrderProxy;
import de.gwtprime.shared.requestFactory.OrderProxy.OrderType;

public class OrderOverviewWidget extends Composite  {

	private static OrderOverviewWidgetUiBinder uiBinder = GWT
			.create(OrderOverviewWidgetUiBinder.class);

	interface OrderOverviewWidgetUiBinder extends
			UiBinder<Widget, OrderOverviewWidget> {
	}
	
	@UiField Label btcLbl;
	@UiField Label btcVal;
	@UiField Label euroVal;
	@UiField Label euroLbl;
	@UiField Label priceLbl;
	@UiField Label priceVal;
	@UiField Label buyOrSellLabel;

	public OrderOverviewWidget(final ClientFactory clientFactory, final OrderProxy order) {
		initWidget(uiBinder.createAndBindUi(this));
		
		 buyOrSellLabel.setText(order.getType()==OrderType.BUY ? "Litecoin Verkaufen" : "Litecoin Kaufen");
		 
			btcLbl.setText(GWTUtils.I18n.btc());
			btcVal.setText(order.getAmount()!=null ? order.getAmount().toString() : "-");
			euroLbl.setText(GWTUtils.I18n.euro());
			euroVal.setText(order.getPrice()!=null ? order.getPrice().toString() : "-");
			priceLbl.setText("Preis:");
			priceVal.setText((order.getAmount()!=null && order.getPrice()!=null) ? String.valueOf(order.getAmount()*order.getPrice()) : "-");
			
	}



}
